/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Action.java
 *
 * Created on 17 juin 2009, 00:49:22
 */

package view.ihm;

import view.com.PgButton;
import java.text.NumberFormat;
import ctrl.sys.ClientSend;
import ctrl.sys.Const;
import ctrl.sys.Demande;
import ctrl.jeu.Table;

/**
 *
 * @author Willy
 */
public class Action2 extends javax.swing.JPanel {

    NumberFormat nf = NumberFormat.getNumberInstance();
    public Table tb;
    /** Creates new form Action */
    public Action2(Table t) {
		nf.setParseIntegerOnly(true);
        this.tb=t;
        initComponents();
        setBackground(Const.couleur);
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        vt_check = new PgButton();
        bt_fold = new PgButton();
        bt_raise = new PgButton();
        Tx_raise = new javax.swing.JFormattedTextField(nf);

        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        vt_check.setText("CHECK");
        vt_check.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vt_checkActionPerformed(evt);
            }
        });
        add(vt_check, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, 100, -1));

        bt_fold.setText("FOLD");
        bt_fold.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_foldActionPerformed(evt);
            }
        });
        add(bt_fold, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 20, 100, -1));

        bt_raise.setText("RAISE");
        bt_raise.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_raiseActionPerformed(evt);
            }
        });
        add(bt_raise, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 80, 100, -1));
        add(Tx_raise, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 80, 100, -1));
    }// </editor-fold>//GEN-END:initComponents

    private void vt_checkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vt_checkActionPerformed

        Demande as=new Demande(Const.CHECK,0,this.tb.getId(),this.tb.getPlaceMain().getIdChaise());
        as.setJ(this.tb.getPlaceMain().getPlayer());
        System.out.println("Demande de check de la chaise : "+this.tb.getPlaceMain().getIdChaise());
        new ClientSend(tb.ClientReseau.getClient(), as).start();
        //new ClientSend(tb.getClientReseau().getClient(),as).start();
        //System.out.println(tb.getClientReseau().getClient());
    }//GEN-LAST:event_vt_checkActionPerformed

    private void bt_raiseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_raiseActionPerformed

        float v=new Float(Tx_raise.getText()).floatValue();
        Demande as=new Demande(Const.RAISE,v,this.tb.getId(),this.tb.getPlaceMain().getIdChaise());
        as.setJ(this.tb.getPlaceMain().getPlayer());
        new ClientSend(tb.ClientReseau.getClient(), as).start();
    }//GEN-LAST:event_bt_raiseActionPerformed

    private void bt_foldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_foldActionPerformed

        Demande as=new Demande(Const.FOLD,0,this.tb.getId(),this.tb.getPlaceMain().getIdChaise());
        as.setJ(this.tb.getPlaceMain().getPlayer());
        new ClientSend(tb.ClientReseau.getClient(), as).start();
    }//GEN-LAST:event_bt_foldActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFormattedTextField Tx_raise;
    private javax.swing.JButton bt_fold;
    private javax.swing.JButton bt_raise;
    private javax.swing.JButton vt_check;
    // End of variables declaration//GEN-END:variables

}
